<?php

class PrivilegeInfo{

    private $mId;
    private $mGroup;
    private $mModule;
    private $mFunction;
    private $mIsAllowAccess;
    private $mIsLoaded;


    public function getId() {
        return $this->mId;
    }
    
    public function setId($value){
        $this->mId = $value;
    }
    
    public function getGroup(){
        if(($this->mGroup != null)&&(!$this->mGroup->isLoaded())){
            $groupDao = new UserGroupDao();
            $this->mGroup = $groupDao->getObject($this->mGroup->getId());
            if ($this->mGroup != null) $this->mGroup->setIsLoaded(true);
        }
        return $this->mGroup;
    }

    public function setGroup($value){
        $this->mGroup = $value;
    }
    
    public function getModule(){
        if(($this->mModule != null)&&(!$this->mModule->isLoaded())){
            $moduleDao = new ModuleDao();
            $this->mModule = $moduleDao->getObject($this->mModule->getId());
            if ($this->mModule != null) $this->mModule->setIsLoaded(true);
        }
        return $this->mModule;
    }
    
    public function setModule($value){
        $this->mModule = $value;
    }
    
    public function getFunctions(){
        if(($this->mFunction != null)&&(!$this->mFunction->isLoaded())){
            $functionsDao = new FunctionsDao();
            $this->mFunction = $functionsDao->getObject($this->mFunction->getId());
            if ($this->mFunction != null) $this->mFunction->setIsLoaded(true);
        }
        return $this->mFunction;
    }
    
    public function setFunctions($value){
        $this->mFunction = $value;
    }
    
    public function getIsAllowAccess(){
        return $this->mIsAllowAccess;
    }
    
    public function setIsAllowAccess($value){
        $this->mIsAllowAccess = $value;
    }

    public function IsLoaded($param) {
        return $this->mIsLoaded;
    }
    
    public function setIsLoaded($value) {
        $this->mIsLoaded = $value;
    }
    
    public function toArray() {
        $data = array(
            'id' => $this->mId,
            'group_id' => $this->mGroup->getId(),
            'module_id' => $this->mModule->getId(),
            'function_id' => $this->mFunction->getId(),
            'is_allow_access' => $this->mIsAllowAccess
        );
        
        return $data;
    }
    
}
